
/**
 * @function checknull
 * @args 输入参数
 *       输入参数为需要进行非空检验的控件ID[ex:employeeNumber]
 **/
function checknull() {
	for (var i = 0; i < arguments.length; i++) {
		var obj = document.getElementById(arguments[i]);
		// 如果必填项目为空,将统一提示"*号为必填项"目,消息取自同级js目录下的资源配置文件
	
		if (obj==null || trim(obj.value) == "" || trim(obj.value) == "null" || trim(obj.value) == "NULL") {
			alert("*号为必填项！");
			if(obj!=undefined && obj!=null ){
				if(!obj.disabled && obj.type != "hidden"){
					obj.focus();
					obj.select();			
				}
			}
			
			return false;
		}
	}
	return true;
}

function clearValue(){
	for (var i = 0; i < arguments.length; i++) {
		var obj = document.getElementById(arguments[i]);
		obj.value='';
	}
}

function checkisnull() {
	for (var i = 0; i < arguments.length; i++) {
		var obj = document.getElementById(arguments[i]);
		// 如果必填项目为空,将统一提示"*号为必填项"目,消息取自同级js目录下的资源配置文件	
		if (obj==null || trim(obj.value) == "" || trim(obj.value) == "null" || trim(obj.value) == "NULL") {
			if(obj!=undefined && obj!=null ){
				if(!obj.disabled && obj.type != "hidden"){
					obj.focus();
					obj.select();			
				}
			}
			
			return false;
		}
	}
	return true;
}

function checkInnerHtmlnull() {
	for (var i = 0; i < arguments.length; i++) {
		var obj = document.getElementById(arguments[i]);
		// 如果必填项目为空,将统一提示"*号为必填项"目,消息取自同级js目录下的资源配置文件
		if (obj==null || trim(obj.innerHTML) == "" || trim(obj.innerHTML) == "null" || trim(obj.innerHTML) == "NULL") {
			alert("*号为必填项！");
			return false;
		}
	}
	return true;
}
function checknull_() {
	for (var i = 0; i < arguments.length; i++) {
		var obj = document.getElementById(arguments[i]);
		// 如果必填项目为空,将统一提示"*号为必填项"目,消息取自同级js目录下的资源配置文件
		if (trim(obj.value) == "" || trim(obj.value) == "null" || trim(obj.value) == "NULL") {
			return false;
		}
	}
	return true;
}

function checknullByJq(){
	for (var i = 0; i < arguments.length; i++) {
		var obj = $("#"+arguments[i]);
		// 如果必填项目为空,将统一提示"*号为必填项"目,消息取自同级js目录下的资源配置文件
		if (trim(obj.val()) == "" || trim(obj.val()) == "null" || trim(obj.val()) == "NULL") {
			//$.messager.alert('提示',"*号为必填项！",'info');
			alert("*号为必填项！");
			if(!obj.disabled){
				obj.focus();
				obj.select();			
			}
			return false;
		}
	}
	return true;
}


function disabledchecknull() {
	for (var i = 0; i < arguments.length; i++) {
		var obj = document.getElementById(arguments[i]);
		// 如果必填项目为空,将统一提示"*号为必填项"目,消息取自同级js目录下的资源配置文件
		if (trim(obj.value) == "" || trim(obj.value) == "null" || trim(obj.value) == "NULL") {
			alert("*号为必填项！");
			return false;
		}
	}
	return true;
}


/**
 * @function lineChecknull
 * @args 输入参数
 *       行信息的非空较验.输入参数为需要进行非空检验的控件ID[ex:employeeNumber]
 **/
function lineChecknull() {
	for (var i = 0; i < arguments.length; i++) {
		var objs = document.getElementsByName(arguments[i]);
		// 如果必填项目为空,将统一提示"*号为必填项"目,消息取自同级js目录下的资源配置文件
		// 第一行为标题头,索引从1开始
		for (var j = 1; j < objs.length; j++) {
			if (trim(objs[j].value) == "") {
				alert("*号为必填项！");
				objs[j].focus();
				objs[j].select();
				return false;
			}
		}
	}
	return true;
}



function singleChecknull(controlId,message) {
	var obj = document.getElementById(controlId);
	if (obj.value == "") {
		//$.messager.alert('提示',message,'info');
		alert(message);
		obj.focus();
		obj.select();
		return false;
	}
	return true;
}


/**
 * @function isEmail 验证输入的是否为电子邮件地址
 * @args email 电子邮件地址
 */
/*
function isEmail(email) {
	return true;
}
*/
/**
 * @function isZipCode 验证输入的是否为邮编
 * @args zipcode 邮编
 */
function isZipCode(zipcode) 
{
	var reg=/^\d{6}$/;
	return reg.test(zipcode);
}
/**
 * @function phoneNumber 验证输入的是否为电话号码
 * @args phoneNumber 电话号码
 */
/*
function isPhoneNumber(phoneNumber) {
	return true;
}
*/
/**
 * @function validateMaxLength
 * @args obj
         maxLength
 */
function validateMaxLength(obj, maxLength) {
	var value = obj.value;
	if (value == undefined || value == "undefined") {
		//$.messager.alert('提示',"error: the component must have 'value' attribute",'info');
		alert("error: the component must have 'value' attribute");
		return false;
	}
	var chineseRegExp = new RegExp("^[\u0391-\uffe5]+$");
	var valueLength = 0;
	for (var i = 0; i < value.length; i++) {
		var temp = value.substring(i, i + 1);
		if (chineseRegExp.test(temp)) {
			valueLength = valueLength + 3;
		} else {
			valueLength++;
		}
		if (valueLength > maxLength) {
			var labObj = obj.parentNode.previousSibling.firstChild;
			var text = "";
			if(labObj != null)
				text = labObj.outerText;
			if(text != null && text.charAt(text.length - 1) == '*')
				text = text.substr(0,text.length - 1);
			var message = "最多只能输入";
			message = message + maxLength;
			// shihengwen 2014-05-20
			message = message + "位字符（一个汉字算三位）";
//			message = text + message;
			//$.messager.alert('提示',message,'info');
			alert(message);
			obj.value = "";
			obj.focus();
			return false;
		}
	}
	return true;
}

/**
 * wuyabin
 * @function validateMaxLength
 * @args obj
         maxLength
         
 */
function valiFCKdateMaxLength(objId, maxLength) {
	var oFck = FCKeditorAPI.GetInstance(objId);
	var value = oFck.EditorDocument.body.innerText;
	if (value == undefined || value == "undefined") {
		//$.messager.alert('提示',"error: the component must have 'value' attribute",'info');
		alert("error: the component must have 'value' attribute");
		return false;
	}
	var chineseRegExp = new RegExp("^[\u0391-\uffe5]+$");
	var valueLength = 0;
	for (var i = 0; i < value.length; i++) {
		var temp = value.substring(i, i + 1);
		if (chineseRegExp.test(temp)) {
			valueLength = valueLength + 2;
		} else {
			valueLength++;
		}
		if (valueLength > maxLength) {
			var obj = document.getElementById(objId);
			var labObj = obj.parentNode.previousSibling.firstChild;
			var text = labObj.outerText;
			if(text != null && text.charAt(text.length - 1) == '*')
				text = text.substr(0,text.length - 1);
			var message = "最多只能输入";
			message = message + maxLength;
			message = message + "位字符（汉字算三位）！";
			message = text + message;
			//$.messager.alert('提示',message,'info');
			alert(message);
			//obj.value = "";
			obj.focus();
			return false;
		}
	}
	return true;
}

/**
 * @function validateMaxLengthOnly
 * update by chengmo 2010-07-16
 * @args obj
 * @args maxLength
 */
function validateMaxLengthOnly(obj, maxLength) {
	var value = obj.value;
	if (value == undefined || value == "undefined") {
		//$.messager.alert('提示',"error: the component must have 'value' attribute",'info');
		alert("error: the component must have 'value' attribute");
		return false;
	}
	var chineseRegExp = new RegExp("^[\u0391-\uffe5]+$");
	var valueLength = 0;
	for (var i = 0; i < value.length; i++) {
		var temp = value.substring(i, i + 1);
		if (chineseRegExp.test(temp)) {
			valueLength = valueLength + 3;
		} else {
			valueLength++;
		}
		if (valueLength > maxLength) {
			var message = "最多只能输入";
			message = message + maxLength;
			message = message + "位字符（汉字算三位）！";
			//$.messager.alert('提示',message,'info');
			alert(message);
			obj.select();
			return false;
		}
	}
	return true;
}
/**
 * @function isDuplicate 判断一个一维对象数据是否重复
 * @args obj
 */
function isDuplicate(obj) {
	var objLen = obj.length;
	for (var i = 0; i < objLen; i++) {
		for (var j = i + 1; j < objLen; j++) {
			if (obj[j] == obj[i]) {
				return true;
			}
		}
	}
	return false;
}
/**
 * @function maxValue 一个文本框的最大数据限制
 *           前置:接收的必须是一个数字
 * @args obj 文本框对象
 		 maxValue 最大值
 */
function maxValue(obj, maxValue) {
	var value = obj.value;
	if (!isNaN(value) && value <= maxValue && value != "") {
		return true;
	}
	var message = "数据定义超出最大值["+ maxValue + "]范围。";
	//$.messager.alert('提示',message,'info');
	alert(message);
	obj.focus();
	return false;
}
/**
 * @function acceptNumber 只接收数字类型的输入
 * @args obj 文本框对象
 		 len 长度
 */
function acceptNumber(obj, len) {
	if (!(event.keyCode >= 48 && event.keyCode <= 57 && obj.value.length < len)) {
		event.returnValue = false;
	}
}
function validatePort(obj) {
	var port = obj.value;
	if (port != "") {
		if (port < 1 || port > 65536 || isNaN(Number(port))) {
			$.messager.alert('提示',"请输入正确的端口号(1-65536)！",'info');
			obj.value = "";
			obj.focus();
		}
		return;
	}
}
function validateIP(obj) {
	var ip = obj.value;
	if (ip != "") {
		var pattern = /^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/;
		if (!pattern.test(ip)) {
			$.messager.alert('提示',"请输入正确的IP！",'info');
			obj.value = "";
			obj.focus();
		}
		return pattern.test(ip);
	}
}
/**
 * @function validatePercent 验证是否为百分比
 * @args obj 值
 */
function validatePercent(obj) {
	var reg = /(?:^(?:[1-9][\d]?)(?:\.[\d]{1,2})?%$)|(?:^100(?:\.0{1,2})?%$)/;
	var value = obj.value;
	if (value != null && value != "") {
		if (!reg.test(value)) {
			var message = $res_entry("message.validate.not.percent.js");
			$.messager.alert('提示',message,'info');
			obj.focus();
			return false;
		}
	}
	return true;
}
/**
 * @function validatePercent 验证是否为百分比(不带%)
 * @args obj 值
 */
function validatePercentNoSign(obj) {
	var reg = /(?:^(?:[0-9][\d]?)(?:\.[\d]{1,2})?$)|(?:^100(?:\.0{1,2})?$)/;
	var value = obj.value;
	if (value != null && value != "") {
		if (!reg.test(value)) {
			obj.value = "";
			var message = "数据格式不正确!(ex:xx.xx)";
			$.messager.alert('提示',message,'info');
			obj.focus();
			return false;
		}
	}
	return true;
}
/**
 * @function validatePercentObjs 验证是否为百分比
 * @args objs 值
 */
function validatePercentObjs() {
	for (var i = 0; i < arguments.length; i++) {
		var obj = document.getElementById(arguments[i]);
		if (!validatePercent(obj)) {
			return false;
			break;
		}
	}
	return true;
}
/**
 * @function validateDate 验证起始日期小于等于结束日期
 * @args startDate -> input calendar开始时间(日期)控件id
         endDate -> input calendar结束时间(日期)控件id
         message -> 提示消息
 */
function validateDate(startDate, endDate, message) {
	var start = getCalendarValue(startDate);
	var end = getCalendarValue(endDate);
	if (start != null && end != null) {
		var differ = Number(end - start);
		if (differ < 0) {
			$.messager.alert('提示',message,'info');
			return false;
		}
	}
	return true;
	/*
	var startDate = document.getElementById(startDate).value;
	var endDate = document.getElementById(endDate).value;
	var strStartDate = startDate.replace(/-/g, "/");
	var strEndDate = endDate.replace(/-/g, "/");
	if (strStartDate.indexOf(":") == -1) {
		strStartDate = strStartDate + " 00:00:00";
	}
	if (strEndDate.indexOf(":") == -1) {
		strEndDate = strEndDate + " 00:00:00";
	}
	var _startDate = new Date(strStartDate);
	var _endDate = new Date(strEndDate);
	var differ = _endDate - _startDate;
	if (differ < 0) {
	}
	return true;
*/
}
/**
 * update by chengmo 2010-2-4
 */
function validateCalendarCurrTime(stratDate, endDate, checkDate, msg) {
	//alert('stratDate='+stratDate+',endDate='+endDate);
	var strat = getCalendarValue(stratDate);
	var end = getCalendarValue(endDate);
	var check = getCalendarValue(checkDate);
	var now = new Date();
	var currDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
	//alert('check='+Number(check)+',currDate='+Number(currDate));
	if (check != null) {
		if (Number(check) < Number(currDate)) {
			$.messager.alert('提示',"输入的时间不能小于当前时间，请重新输入！",'info');
			setCalendarValue(checkDate, "");
			return false;
		}
	}
	if (strat != null && end != null) {
		if (Number(end) < Number(strat)) {
			$.messager.alert('提示',msg,'info');
			setCalendarValue(checkDate, "");
			return false;
		}
	}
	return true;
}


function validateCalendarBeforeDate(stratDate, msg) {
	var strat = getCalendarValue(stratDate);
	var now = new Date();
	var currDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
	if (strat != null) {
		if (Number(strat) > Number(currDate)) {
			$.messager.alert('提示',msg,'info');
			setCalendarValue(stratDate, "");
			return false;
		}
	}
	return true;
}
/**
 * update by chengmo 2010-2-4
 */
function validateCalendarCurrDate(stratDate, endDate, checkDate, msg1, msg2, msg3) {
	//alert('stratDate='+stratDate+',endDate='+endDate);
	var strat = getCalendarValue(stratDate);
	var end = getCalendarValue(endDate);
	var now = new Date();
	var currDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
	if (strat != null) {
		if (Number(strat) < Number(currDate)) {
			$.messager.alert('提示',msg1,'info');
			setCalendarValue(stratDate, "");
			return false;
		}
	}
	if (end != null) {
		if (Number(end) < Number(currDate)) {
			$.messager.alert('提示',msg2,'info');
			setCalendarValue(endDate, "");
			return false;
		}
	}
	if (strat != null && end != null) {
		if (Number(end) < Number(strat)) {
			$.messager.alert('提示',msg3,'info');
			setCalendarValue(stratDate, "");
			setCalendarValue(endDate, "");
			return false;
		}
	}
	return true;
}
/**
 * update by chengmo 2010-2-4
 */
function validateCalendar(stratDate, endDate, checkDate, msg) {
	//alert('stratDate='+stratDate+',endDate='+endDate);
	var strat = getCalendarValue(stratDate);
	var end = getCalendarValue(endDate);
	if (strat != null && end != null) {
		if (Number(end) < Number(strat)) {
			$.messager.alert('提示',msg,'info');
			setCalendarValue(checkDate, "");
			return false;
		}
	}
	return true;
}

/**
 * update by chengmo 2010-5-25
 */
function validateInputCalendar(stratId, endId, checkId, format, msg) {
	//alert('stratDate='+stratDate+',endDate='+endDate);
	var strat = getInputCalendarValue(stratId, format);
	var end = getInputCalendarValue(endId, format);
	if (strat != null && end != null) {
		if (Number(end) < Number(strat)) {
			$.messager.alert('提示',msg,'info');
			document.getElementById(checkId).value = '';
			return false;
		}
	}
	return true;
}

/**
 * update by chengmo 2010-5-25
 */
function getInputCalendarValue(id, format) 
{
	var obj = document.getElementById(id);
    var time = obj.value;
    return getCalendarUTCfromTime(format, time);
}

/**
 * update by chengmo 2010-2-4
 */
function checkDateNull() {
	for (var i = 0; i < arguments.length; i++) {
		var obj = document.getElementById(arguments[i]);
		var targetId = obj.getAttribute("target");
		var obj1 = document.getElementById(targetId);
		var value = obj1.value;
		// 如果必填项目为空,将统一提示"*号为必填项"目,消息取自同级js目录下的资源配置文件
		if (trim(value) == "" || trim(value) == "null" || trim(value) == "NULL") {
			//$.messager.alert('提示',"温馨提示:*号为必填项！",'info');
			alert("温馨提示:*号为必填项！");
			obj1.focus();
			obj1.select();
			return false;
		}
	}
	return true;
}

function trim(str)
{
    var num = str.length;
    var i = 0;
    for(i = 0; i < num;i++) {
        if(str.charAt(i) != " ")
            break;
    }
    str = str.substring(i);
    num = str.length;
    for(i = num-1; i > -1;i--) {
        if(str.charAt(i) != " ")
            break;
    }
    str = str.substring(0, i+1);
    return str;
};
/**
 * update by chengmo 2010-2-4
 */
function isPhoneNumber(objId) {
	var obj = document.getElementById(objId);
	//alert(11111);
	var value = obj.value;	
	if (value != "") {
		var me = false;
		var reg = /^[0-9]{3,4}\-[0-9]{3,8}$/;
		if (reg.test(value)) {
			me = true;
		}	
		if (!me) {
			obj.value = "";
			//$.messager.alert('提示',"输入的联系电话格式不正确，请重新输入！",'info');
			alert("输入的联系电话格式不正确，请重新输入！");
			obj.focus();
			return ;
		}
	}
	
	return true;
}


function isMobiles(objId){
	var obj = document.getElementById(objId);
	if (obj.value == "") {
		return false;
	}
	//var mobiles = obj.value.split(",");
	var mobiles = obj.value;
	var reg0 = /^(13[0-9]\d{8})|(15[0-9]\d{8})|(18[0-9]\d{8})$/;
//	var reg0 = /^((13[0-9])|(15[^4,\D])|(18[0,5-9]))\d{8}$/ ;
//	var reg0=/^1\d\d{5,9}$/;   //130--139。至少7位
	//var reg1=/^15\d{5,9}$/;  //150--159联通153。至少7位
	
	//for(var i = 0; i < mobiles.length; i ++){
		var my=false;
		if (reg0.test(mobiles))
			my=true;
		//if (reg1.test(mobiles[i]))my=true;
		var result=mobiles.match(/\d{3}\d{8}|\d{3,4}-\d{7,8}/);
		if(result!=null){
			my=true;
		}else{
			my=false;
		}
		if (!my){
			//obj.value = "";
			//$.messager.alert('提示',"输入的手机号码不正确，请重新输入！",'info');
			// shihengwen 2014-05-08
			alert("输入的手机号码格式不正确，请重新输入！");
			obj.focus();
			obj.select();
			return false;
		}
	//}
	return true;
}
function isMobiles_(value){
	if (value == "") {
		return false;
	}
	//var mobiles = obj.value.split(",");
	var mobiles = value;
	var reg0 = /^(13[0-9]\d{8})|(15[0-9]\d{8})|(18[0-9]\d{8})$/;
	var my=false;
	if (reg0.test(mobiles))
		my=true;
	//if (reg1.test(mobiles[i]))my=true;
	var result=mobiles.match(/\d{3}\d{8}|\d{3,4}-\d{7,8}/);
	if(result!=null){
		my=true;
	}else{
		my=false;
	}	if (!my){
		//obj.value = "";
		//$.messager.alert('提示',"输入的手机号码不正确，请重新输入！",'info');
		alert("输入的手机号码不正确，请重新输入！");
		my=false;
	}
	//}
	return my;
}
/**
*用户名验证
*/
function isUserCode(num) {
	if (num == "") {
		return true;
	}
	var  pattern=/[\u4e00-\u9fa5]/g;//不能为中文
	if(num.search("_")>=0||pattern.test(num))
	{
	return false;
	}
	return true;
}
/**
*密码
*/
function isPassWord(num) {
	if (num == "") {
		return true;
	}
	var reg =/([A-Za-z]|[~!@#$%^&*()-|]){1,20}[0-9]{1,20}|([0-9]|[~!@#$%^&*()-|]){1,20}[A-Za-z]{1,20}/;///^([a-zA-Z0-9\-]){6,20}$/;
	var str=/^[A-Za-z]+$/;
	var re = /^[0-9]+.?[0-9]$/;
	if (reg.exec(num)&&!re.test(num)&&!str.test(num)) {
		return true;
	} else {
		return false;
	}
	return true;
}
/**
*字符串中包含几个特殊字符
*/
function isMatch(str)
{
	var vcar=new Array('~','!','@','#','$','%','^ ','&','*','(',')','-','|','/');
	var count=0;
		for(var j=0;j<vcar.length;j++)
		{
			if(str.indexOf(vcar[j])!= -1)
			{
			count++;
			}
		}
	return count;
}
/**
*用户名验证
*/
function isUserName(name)
{
	if (name == "") {
		return true;
	}
	var reg =/^(([a-zA-Z0-9]|[_-]){4,20}|([a-zA-Z0-9]|[\u4E00-\u9FA5]){2,20}|[\u4E00-\u9FA5]{2,10})$/;
	//var reg =/^([\u4E00-\uFA29]{2,10}|[\uE7C7-\uE7F3]{4,20}|[a-zA-Z0-9]{4,20})*$/;
	var length = name.replace(/[^\x00-\xff]/g,"**").length;  
	//if (reg.test(name)) {
	if (reg.exec(name)&&length>3) {
		return true;
	} else {
		return false;
	}
}
function isEmail2(value) {
	var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (value != "" && !reg.test(value)) {
		return false;
	}
	return true;
}
/**
 * 验证邮编
 * @param obj
 * @returns {Boolean}
 */
function isZipcode(objId) {
	var obj = document.getElementById(objId);
	if (obj.value == "") {
		return true;
	}
	var reg =/^\d{6}$/;
	if (reg.test(obj.value)) {
		return true;
	} else {
		//obj.value = "";
		//$.messager.alert('提示',"输入的邮编不正确，请重新输入！",'info');
		alert("输入的邮编不正确，请重新输入！");
		obj.focus();
		return false;
	}
}

function isZipcode_(value) {
	if (value == "") {
		return true;
	}
	var reg =/^\d{6}$/;
	if (reg.test(value)) {
		return true;
	} else {
		alert("输入的邮编不正确，请重新输入！");
		return false;
	}
}

/**
 * 验证手机号码
 * @param obj
 * @returns {Boolean}
 */
function isMobile(obj) {
	if (obj.value == "") {
		return true;
	}
	var reg = /^((18[0-9]{1})|(13[0-9]{1})|(15[0, 8, 0]{1})){1}\d{8}$/;
	if (reg.test(obj.value)) {
		return true;
	} else {
		obj.value = "";
		//$.messager.alert('提示',"输入的手机号码不正确，请重新输入！",'info');
		alert("输入的手机号码不正确，请重新输入！");
		obj.focus();
		return false;
	}
}

function isMobile_(value) {
	if (value == "") {
		return true;
	}
	var reg = /^((18[0-9]{1})|(13[0-9]{1})|(15[0, 8, 0]{1})){1}\d{8}$/;
	if (reg.test(value)) {
		return true;
	} else {
		alert("输入的电话号码不正确，请重新输入！");
		return false;
	}
}

/**
 * 验证电话号码
 * @param obj
 * @returns {Boolean}
 */
function isPhone(obj) {
	if (obj.value == "") {
		return true;
	}
	var reg = /^(([0\+]\d{2,3}-)?(0\d{2,3})-)?(\d{7,8})(-(\d{1,}))?$/;
	if (reg.test(obj.value)) {
		return true;
	} else {
		obj.value = "";
		//$.messager.alert('提示',"输入的电话号码不正确，请重新输入！",'info');
		alert("输入的电话号码不正确，请重新输入！");
		obj.focus();
		return false;
	}
}


function isNumber(data){
	var num = document.getElementById(data).value;
	if(num == "") {
		return false;
	}else if (data == "price" || data == "spend") {
		var pattern = /,/g;
		num = num.replace(new RegExp(pattern), "");
	}
	var reg = /^[0-9]+[0-9]*$/;
	if(!reg.test(num)){
		//$.messager.alert('提示',"输入不合法，请输入数字！",'info');
		alert("输入不合法，请输入数字！");
		return false;
		}
	return true;
}

function isNumberNull(data){
	var num = document.getElementById(data).value;
	if(num != undefined && num != null && num != "") {
		var reg = /^[0-9]+[0-9]*$/;
		if(!reg.test(num)){
			//$.messager.alert('提示',"输入不合法，请输入数字！",'info');
			alert("输入不合法，请输入数字！");
			return false;
			}
	}
	return true;
}

function isNumber_(data){
	var num = document.getElementById(data).value;
	if(num == "") return false;
	var reg = /^[0-9]+[0-9]*$/;
	if(!reg.test(num)){
		//$.messager.alert('提示',"输入不合法，请输入数字！",'info');
		document.getElementById(data).value="";
		document.getElementById(data).focus();
		alert("输入不合法，请输入数字！");
		return false;
	}
	return true;
}

function isNumber__(num){
	if(num == "") return false;
	var reg = /^([1-9]+[0-9]*)|0$/;
	if(!reg.test(num)){
		alert("输入不合法，请输入数字！");
		return false;
	}
	return true;
}

function isNumberBank(data){
	var num = document.getElementById(data).value;
	if(num == "") return false;
	var reg = /^[1-9]+[0-9]*$/;
	if(!reg.test(num)){
		$.messager.alert('提示',"银行账号输入不合法，请输入数字！",'info');
		return false;
		}
	return true;
}
/**
 * update by jjx 2010-07-07
 */
function isEmails(objId) {
	var obj = document.getElementById(objId);
	if(obj.value == ""){
		return true;
	}
	var values = obj.value.split(",");
	var reg = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	for(var i = 0; i < values.length; i ++){
		if (!reg.test(values[i])) {
			//obj.value = "";
			//$.messager.alert('提示',"输入的联系邮箱不正确，请重新输入！",'info');
			alert("输入的联系邮箱不正确，请重新输入！");
			obj.focus();
			return false;
		}
		
	}
	return true;
}
/**
 * update by chengmo 2010-2-4
 */
function validateCalendarNow(calenderId) {
	//alert('stratDate='+stratDate+',endDate='+endDate);
	var calenderValue = getCalendarValue(calenderId);
	var now = new Date();
	var currDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
	if (calenderValue != null) {
		if (Number(calenderValue) < Number(currDate)) {
			$.messager.alert('提示',"输入的时间不能小于当前时间，请重新输入！",'info');
			setCalendarValue(calenderId, "");
			return false;
		}
	}
	return true;
}
/**
 * add by jjx 2010-05-11
 */
function validateCalendarLtNow(calenderId) {
	var calenderValue = getCalendarValue(calenderId);
	var now = new Date();
	var currDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
	if (calenderValue != null) {
		if (Number(calenderValue) > Number(currDate)) {
			$.messager.alert('提示',"输入的时间不能大于当前时间，请重新输入！",'info');
			setCalendarValue(calenderId, "");
			return false;
		}
	}
	return true;
}

/**
 * add by jjx 2010-06-28
 */
function validateCalendarLtNow2(calenderId) {
	var calenderValue = getCalendarValue(calenderId);
	var now = new Date();
	
	if (calenderValue != null) {
		if (Number(calenderValue) > Number(now)) {
			$.messager.alert('提示',"结束时间不能大于当前时间，请重新输入！",'info');
			//setCalendarValue(calenderId, "");
			return false;
		}
	}
	return true;
}
/**
 * 去除所有空格
 */
 function delblank(str) {
 if(str==null) return null;
 	return str.replace(/\s+/g,""); 
 }
 /**
  *  去掉字符串 的头尾空格
  * @param obj
  */
 function  deltrim(obj){ 
	 var values=$(obj).val();
	if(''!=$(obj).val()){
		$(obj).val(values.replace(/(^\s*)|(\s*$)/g, "")); 
	   }
	}
/**
 * 验证表格是否有数据
 * @param {} tab
 * @param {} msg
 */			
function checkTable(tab, msg)
{
	if(msg == undefined)
		msg = '没有数据！';
		
	var pagetable = new PageZTable(tab);
	if(pagetable.rows.length <= 1)
	{
		$.messager.alert('提示',msg,'info');
	}
}

function strDateTime(str)
{
	var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;
	var r = str.match(reg);
	if(r==null)return false;
	var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]);
	$.messager.alert('提示',JSON.stringify(d),'info');
	return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]);
}


/**
*验证只能输入数字支持小键盘
*裴俊武
*/
function acceptNumbers(obj, len) {
	if (!(((event.keyCode >= 48 && event.keyCode <= 57)||(event.keyCode>=96 && event.keyCode<=105 ))  && obj.value.length < len || event.keyCode == 8)) {
		event.returnValue = false;
	}
}

/**
*验证日期格式为：YYYY-MM-DD HH-MM-SS
*pjw
*/
function strDateTime(datestr)
{
	var str = $('#'+datestr).datebox('getValue');
	var flag = false;
	var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;
	var r = str.match(reg);
	
	if(r!=null){
		var d= new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]);
		flag = (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]);
	}
	if(!flag){
		$.messager.alert('提示',"时间格式为YYYY-MM-DD HH:MM:SS",'info');
		$('#'+datestr).datebox('setValue','');
		$('#'+datestr).focus();
		return false;
	}
	return true;
}
/**
*验证日期格式为：YYYY-MM-DD
*/
function strDate(datestr)
{
	var str = $('#'+datestr).datebox('getValue');
	var flag = false;
	var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/;
	var r = str.match(reg);
	
	if(r!=null){
		var d= new Date(r[1], r[3]-1,r[4]);
		flag = (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);
	}
	if(!flag){
		$.messager.alert('提示',"时间格式为YYYY-MM-DD",'info');
		$('#'+datestr).datebox('setValue','');
		$('#'+datestr).focus();
		return false;
	}
	return true;
}

/**
*验证日期前后
*/
function checkStartAndEndDate(startdate,enddate)
{
	var startdatestr = $('#'+startdate).datebox('getValue');
	var enddatestr = $('#'+enddate).datebox('getValue');
	var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/;
	var r1 = startdatestr.match(reg);
	var r2 = enddatestr.match(reg);
	
	if(r1!=null && r2 != null){
		var s= new Date(r1[1], r1[3]-1,r1[4]);
		var e= new Date(r2[1], r2[3]-1,r2[4]);
		if (Number(s) > Number(e)) {
			$.messager.alert('提示',"完成日期应大于启动日期！",'info');	
			$('#'+enddate).datebox('setValue','');
			$('#'+enddate).focus();		
			return false;
		}
	}
	return true;
}

/**
*验证下拉框不为空
*pjw
*/
function comBoxcheck(str){
	var val = $('#'+str).combobox('getValue');
	if (trim(val) == "" || trim(val) == "null" || trim(val) == "NULL") {
			//$.messager.alert('提示',"温馨提示:*号为必填项！",'info');
		alert("温馨提示:*号为必填项！");
			return false;
		}
	return true;
}	



function comBoxcheck_comm(str){
	var val = $('#'+str).val();
	if (trim(val) == "" || trim(val) == "null" || trim(val) == "NULL") {
			$.messager.alert('提示',"温馨提示:*号为必填项！",'info');
			$('#'+str).focus();
			$('#'+str).select();
			return false;
		}
	return true;
}	


/*验证银行账户
 * 
 */
function checkbankNum(str){
	var account = $('#'+str).val();
	var reg = /^\d{16}$/g;   // 以19位数字开头，以19位数字结尾
	if( !reg.test(account) )
	{
		$.messager.alert('提示',"银行账户格式错误，应该是16位数字！",'info');
		$('#'+str).focus();
		$('#'+str).select();
		return false;
	}
	return true;
}

//验证是否为年份
function validYear(element){
	var val = $('#'+element).val();
	var sTest=/(?:(?:1[8-9]|[2][0-9])\d{2})|(?:6000)/;
	if(!sTest.test(val)){
		$.messager.alert('提示',"请输入正确的年份，格式为四位数字！",'info');
		$('#'+element).focus();
		$('#'+element).select();
		return false;
	}
	return true;
}


/**
 * 支持中英文判断输入字符长度
 * @param target_obj 目标参数
 * @param max_length 最大长度
 * @author PJW
 * @returns
 */
function compute_byte(target_obj,max_length) {
    var target_obj_val = $(target_obj).val();
    var flag = true;
    if(target_obj_val != "" && target_obj_val != null && target_obj_val != "undefined"){
    	 var realLength = 0, len = target_obj_val.length, charCode = -1;
 	    for (var i = 0; i < len; i++) {
 	        charCode = target_obj_val.charCodeAt(i);
 	        if (charCode >= 0 && charCode <= 128) realLength += 1;
 	        else realLength += 3;
 	    }
 	    
 	    if(realLength > max_length){
 	    	$.messager.alert("提示",'最大可输入'+max_length+'字符',"info",function(){
 	    		$(target_obj).val('');
 	    		target_obj.focus();		 	    	
 	    	}); 
 	    	flag = false;
 	    }
    }
    return flag;
}

//查询验证日期(格式只试用于：yyyy-mm-dd) 例如：不能大于当前时间
function ckickDate(startdate,enddate,msg)
{
	var r1 = null;
	var r2 = null;
	//根据ID得到日期值并拆分成数组(起始日期和结束日期)
	var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/;
	if(startdate!=null){
		var startdatestr = $('#'+startdate).datebox('getValue');
		r1 = startdatestr.match(reg);
	}
	if(enddate!=null){
		var enddatestr = $('#'+enddate).datebox('getValue');
		r2 = enddatestr.match(reg);
	}
	//得到当前日期
	var now = new Date();
	var currDate = new Date(now.getFullYear(), now.getMonth(), now.getDate());
	
	//检查起始日期是否大于当前日期
	if(r1!=null)
	{
		var s= new Date(r1[1], r1[3]-1,r1[4]);
		if(Number(s) > Number(currDate))
		{
			 
			$.messager.alert('提示',msg,'info',function(){
				
			});
			$('#'+startdate).datebox('setValue','');
			return false;
		}
	}
	//检查结束日期是否大于当前日期
	if(r2!=null)
	{
		var e= new Date(r2[1], r2[3]-1,r2[4]);
		if(Number(e) > Number(currDate))
		{
			$.messager.alert('提示',msg,'info',function(){
				
			});
			$('#'+enddate).datebox('setValue','');
			return false;
		}
	}
	//查检起始日期是否大于结束日期
	if(r1!=null && r2 != null){
		var s= new Date(r1[1], r1[3]-1,r1[4]);
		var e= new Date(r2[1], r2[3]-1,r2[4]);
		if (Number(s) > Number(e)) {
			$.messager.alert('提示',msg,'info');	
			$('#'+enddate).datebox('setValue','');
			return false;
		}
	}
	return true;
}

function isIdentifier(id,msg) { 
	var obj = document.getElementById(id);
    //对电子邮件的验证
    //var myreg = (/(^\d{15}$)|(^\d{17}([0-9]|X)$)/;
 
	if(obj.value!=""){
		if (!(/(^\d{15}$)|(^\d{17}([0-9]|X)$)/.test(obj.value)))  
	    {
	         $.messager.alert('消息',msg,'info',function(){
	        	 obj.focus();
	             obj.select();
	         });
	         return false;
	   }
	}
    
   return true;
}

/**
 * 验证网址
 * @param obj
 * @returns {Boolean}
 */
function isWebsite(obj) {
//	if (obj.value == "") {
//		return true;
//	}
//	var reg = /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
//	//var reg = /^((18[0-9]{1})|(13[0-9]{1})|(15[0, 8, 0]{1})){1}\d{8}$/;
//	if (reg.test(obj.value)) {
//		return true;
//	} else {
//		obj.value = "";
//		//$.messager.alert('提示',"输入的手机号码不正确，请重新输入！",'info');
//		alert("输入的网址不正确，请重新输入！如：http://www.baidu.com");
//		obj.focus();
//		return false;
//	}
	return true;
}

function isWebsite_(value) {
//	if (value == "") {
//		return true;
//	}
//	var reg = /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i;
//	//var reg = /^((18[0-9]{1})|(13[0-9]{1})|(15[0, 8, 0]{1})){1}\d{8}$/;
//	if (reg.test(value)) {
//		return true;
//	} else {
//		alert("输入的网址不正确，请重新输入！如：http://www.baidu.com");
//		return false;
//	}
	return true;
}

function isMoney(obj) {
	if (obj.value == "") {
		return true;
	}
	var reg = /^\d+(\.\d\d)?$/;
	if (reg.test(obj.value)) {
		return true;
	} else {
		obj.value = "";
		//$.messager.alert('提示',"输入的手机号码不正确，请重新输入！",'info');
		alert("输入的格式不正确，请重新输入！");
		obj.focus();
		return false;
	}
}

function isMoney_(value) {
	if (value == "") {
		return true;
	}
	var reg = /^(([1-9]{1}\d*)|([0]{1}))(\.(\d){0,2})?$/;
	if (reg.test(value)) {
		return true;
	} else {
		alert("输入的格式不正确，请重新输入！");
		return false;
	}
}

function isFax_(data){
	var num = document.getElementById(data).value;
	if(num == "") return false;
	var reg = /^((\+?[0-9]{2,4}\-[0-9]{3,4}\-)|([0-9]{3,4}\-))?([0-9]{7,8})(\-[0-9]+)?$/;
	if(!reg.test(num)){
		//$.messager.alert('提示',"输入不合法，请输入数字！",'info');
		document.getElementById(data).value="";
		document.getElementById(data).focus();
		alert("输入传真不合法，请输入数字！");
		return false;
	}
	return true;
} 
//判断日期大小
function compDate(startdate,enddate){
	var ass,aD,aS;
	var bss,bD,bS;
	var  begin=document.getElementById(startdate).value; //开始时间；
	var  over=document.getElementById(enddate).value;    //结束时间； 
	if(begin=="") return false;
	if(over=="") return false;
	
	ass=begin.split("-");         //以"-"分割字符串，返回数组；
	aD=new Date(ass[0],ass[1],ass[2]);   //格式化为Date对象;
	aS=aD.getTime(); //得到从 1970 年 1 月 1 日开始计算到 Date 对象中的时间之间的毫秒数

	bss=over.split("-");
	bD=new Date(bss[0],bss[1],bss[2]);
	bS=bD.getTime();
	if(aS>bS){
	    alert("开始日期不能超过结束日期");
	    document.getElementById(startdate).value="";
		document.getElementById(startdate).focus();
		return false;
	 } 
	return true;
}

/**
 * 验证正整数
 * shihengwen 
 * 2014.05.26
 * */
var reg = /^[0-9]*[1-9][0-9]*$/;
function isPositiveNum(num){
	if(num == "") return false;
	if(!reg.test(num)){
		alert("输入不合法，请输入数字！");
		return false;
	}
	return true;
}

function getsave(){
	var obj1=document.getElementById("nane");
	var obj2=document.getElementById("content");
	var name=obj1.value;
	var content=obj2.value;
	if(name.length > 100) {
		alert("请将消息名称控制在100字以内！");
		return false;
	}
	if(content.length > 500) {
		alert("请将消息内容控制在500字以内！");
		return false;
	}
	if(name==""){
		alert("*号为必填项！");
			if(!obj1.disabled){
				obj1.focus();
				obj1.select();			
			}
		return false;
	}else if(content==""){
		alert("*号为必填项！");
			if(!obj2.disabled){
				obj2.focus();
				obj2.select();			
			}
		return false;
	}else{
		document.getElementById("editForm").submit();
		return true;
	}
}


var reg0 = /^1[3|4|5|8][0-9]\d{4,8}$/;
function checkMobile(objId){ 
	var obj = document.getElementById(objId);
	if (obj.value == "") {
		return false;
	}
	var sMobile = obj.value;
    if(!(reg0.test(sMobile))){ 
        alert("不是完整的11位手机号或者正确的手机号前七位"); 
        obj.focus();
		obj.select();
		return false; 
    } 
    return true;
} 

function getRootPath(){
    var curWwwPath=window.document.location.href;
    var pathName=window.document.location.pathname;
    var pos=curWwwPath.indexOf(pathName);
   
    var localhostPaht=curWwwPath.substring(0,pos);
//    var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
//    return(localhostPaht+projectName);
    return(localhostPaht);
}

/**
 * 去掉所有空格，统计字数
 * */
var port = 8090;
function delHtmlTag(str)
{
	if(str == null)
		return str;
	
    str = str.replace (/<\/?[^>]*>/gim, "");	    //去掉所有的html标签 
    var result = str.replace(/(\s*)|(\s*$)/g, "");	//去掉前后空格     
    result = result.replace (/\s/g, "");				//去除文章中心空格    
    result = result.replace(/\&nbsp;/g, "");		//去除&nbsp;空格    
    
	return result.replace(/^( |[\s　])+|( |[\s　])+$/g, ""); 
}


function isNotCardNo(cardId, msg)  
{  
   // 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X  
   var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; 
   var obj = document.getElementById(cardId);
   
   if (obj.value == "") {
		return false;
   }
   if(reg.test(obj.value) === false)  { 
	   if(msg == ""){
		   msg = "身份证输入不合法，请重新输入。";
	   }
	   alert(msg);
	   obj.focus();
	   obj.select();
       return true;
   }  
   
   return false;
}  

/**
 * 限制权重值
 * */
function vaiPriority(id) {
	var obj = document.getElementById(id);
	if (obj != null) {
		var priority = parseInt(obj.value);
		if (0 <= priority && priority <= 100) {
			return true;
		}
		obj.focus();
	}
	return false;
}

/**
 * 列表图片限制
 * */
function getListWidth(){
	return 181;
}

function getListHeight(){
	return 120;
}
